const { resolve } = require('path')

const mongoose = require(resolve(__dirname, '../db'))

const ArticlesSchema = mongoose.model('articles', new mongoose.Schema({
  title: { // 标题
    type: String,
    required: [true, '标题不可为空!'],
    trim: true
  },
  articleCover: { // 文章封面
    type: String,
    trim: true
  },
  introduction: { // 简介
    type: String,
    trim: true
  },
  category: { // 分类
    type: String,
    trim: true
  },
  tag: { // 标签
    type: String,
    trim: true
  },
  commentLikeFavorites: { // 评论点赞收藏
    type: String,
    trim: true
  },
  articleStatus: { // 文章状态
    type: String,
    trim: true
  },
  articleContent: {  // 文章内容
    type: String,
    trim: true
  },
  createTime: {  // 创建时间
    type: Number,  // 时间戳
    min: [1, '时间格式错误'],
    trim: true
  },
  updateTime: {  // 修改时间
    type: Number,  // 时间戳
    trim: true
  },
  isDel: { // 是否删除
    type: Boolean,
    trim: true,
    default: false
  }
}))

module.exports = ArticlesSchema
